import axiosInstance from '@/api/utils/request'
import { LOGIN_URL, GET_USERINFO_URL, GET_UPLOAD_POLICY_URL } from './apiconfig'
import { Modal } from 'ant-design-vue'

export const login = (userAccount) => {
  return axiosInstance
    .post(LOGIN_URL, userAccount, {
      headers: {
        'Content-Type': 'application/json'
      }
    })
    .then((res) => {
      if (res.code !== 'SUC000') {
        Modal.error({
          title: res.code,
          content: res.message
        })
      } else {
        return res.data
      }
    })
}

export const getUserInfo = () => {
  return axiosInstance
    .post(
      GET_USERINFO_URL,
      {},
      {
        headers: {
          'Content-Type': 'application/json'
        }
      }
    )
    .then((res) => {
      if (res.code === 'SUC000') {
        return res
      }
    })
}

export const getDownloadPolicy = ()=>{
  return axiosInstance
  .post(
    GET_UPLOAD_POLICY_URL,
    {},
    {
      headers: {
        'Content-Type': 'application/json'
      }
    }
  )
  .then((res) => {
    if (res.code === 'SUC000') {
      return res
    }
  })
}
